<template>
    <d2-container type="card">
        <header>
            <el-form :inline="true" :model="selectFrom" class="demo-form-inline" size="mini">
                <el-form-item label="用户名称">
                    <el-input v-model="selectFrom.userId" placeholder="用户名称" clearable></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="getComFeedbackData()">查询</el-button>
                </el-form-item>
            </el-form>
        </header>
        <footer>
            <el-table :data="tableData" border style="width: 100%" size="mini" :height="height">
                <el-table-column prop="id" label="反馈编号" align="center" fixed="left" :show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column prop="userId" label="反馈用户" align="center" fixed="left" :show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column prop="imageUrlList" label="反馈图片" align="center">
                    <template slot-scope="scope">
                    <div class="demo-image__preview">
                        <el-image
                        ref="preview"
                        style="width: 80px; height: 80px"
                        :src="scope.row.imageUrlList[0]"
                        :preview-src-list="scope.row.imageUrlList"
                        >
                        </el-image>
                    </div>
                    </template>
                </el-table-column>
                <el-table-column prop="describe" label="描述" align="center" fixed="left" :show-overflow-tooltip="true">
                </el-table-column>
            </el-table>
            <div class="block" style="text-align:center">
                <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="page"
                    :page-sizes="[5, 10, 15, 20]" :page-size="limit" layout="total, sizes, prev, pager, next, jumper"
                    :total="total">
                </el-pagination>
            </div>
        </footer>
    </d2-container>
</template>
  
<script>
import { getComFeedback } from "@/api/modules/com_feedback.js"
export default {
    name: 'ComFeedback',
    data() {
        return {
            selectFrom: {},//搜索栏
            tableData: [],//表格数据
            page: 1,
            limit: 10,
            total: 0,
            height: window.innerHeight - 250, //表格高度
            from: {},//反馈数据
            tableloading: false,//表格数据
        }
    },
    mounted() {
        this.getComFeedbackData();
        //-------------------------表格响应----------------//
        this.createHeight();
        //当页面发生变化时，表格高度固定
        window.onresize = () => {
            return (() => {
                this.$nextTick(() => {
                    this.createHeight();
                });
            })();
        };
    },
    methods: {
        //获取反馈数据
        getComFeedbackData() {
            this.selectFrom.page = this.page;
            this.selectFrom.limit = this.limit;
            this.tableloading = true;
            getComFeedbackBack(this.selectFrom).then(res => {
                this.tableData = res.dataList;
                this.total = res.total;
                this.tableloading = false;
            })
        },
        handleSizeChange(val) {
            this.limit = val;
            this.getComFeedbackData();
        },
        handleCurrentChange(val) {
            this.page = val;
            this.getComFeedbackData();
        },
        //---------------自动变更表格高度------------------//
        createHeight() {
            this.height = window.innerHeight - 250;
        }
    }
}
</script>
  